﻿using System;

namespace NEnsure.Rules
{
	public class ManualValidationRule<T> : BaseBusinessRule<T>, IBusinessRule<T>
	{
		private readonly IInspector<T> _inspector;

		public override string RuleKey
		{
			get { return "Manual-Validation Rule"; }
		}

		public ManualValidationRule(IInspector<T> inspector)
			: base(inspector.ErrorFormat)
		{
			if (inspector == null)
			{
				throw new ArgumentNullException("inspector");
			}

			_inspector = inspector;
		}

		public bool IsBrokenBy(T value)
		{
			return _inspector.Inspect(value);
		}
	}
}
